package com.tencreat.service.account.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.tencreat.domain.account.CommonWithdrawConfig;
import com.tencreat.mapper.account.CommonWithdrawConfigMapper;
import com.tencreat.service.account.ICommonWithdrawConfigService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 提现设置Service业务层处理
 *
 * @author tencreat
 * @date 2021-09-11
 */
@Service
public class CommonWithdrawConfigServiceImpl extends ServiceImpl<CommonWithdrawConfigMapper, CommonWithdrawConfig> implements ICommonWithdrawConfigService {


    /**
     * 查询提现设置
     *
     * @param id 提现设置ID
     * @return 提现设置
     */
    @Override
    public CommonWithdrawConfig selectCommonWithdrawConfigById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询提现设置列表
     *
     * @param commonWithdrawConfig 提现设置
     * @return 提现设置
     */
    @Override
    public List<CommonWithdrawConfig> selectCommonWithdrawConfigList(CommonWithdrawConfig commonWithdrawConfig) {
        return baseMapper.selectList(Wrappers.query(commonWithdrawConfig));
    }

    /**
     * 新增提现设置
     *
     * @param commonWithdrawConfig 提现设置
     * @return 结果
     */
    @Override
    public int insertCommonWithdrawConfig(CommonWithdrawConfig commonWithdrawConfig) {
        return baseMapper.insert(commonWithdrawConfig);
    }

    /**
     * 修改提现设置
     *
     * @param commonWithdrawConfig 提现设置
     * @return 结果
     */
    @Override
    public int updateCommonWithdrawConfig(CommonWithdrawConfig commonWithdrawConfig) {
        commonWithdrawConfig.setUpdateTime(LocalDateTime.now());



        return baseMapper.updateById(commonWithdrawConfig);
    }

    /**
     * 批量删除提现设置
     *
     * @param ids 需要删除的提现设置ID
     * @return 结果
     */
    @Override
    public int deleteCommonWithdrawConfigByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除提现设置信息
     *
     * @param id 提现设置ID
     * @return 结果
     */
    @Override
    public int deleteCommonWithdrawConfigById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
